"""
Python的面向对象

面向过程：以线性的流程为基本单位，通过函数和事物的逻辑进行实现程序的设计和实现。

面相对象：以对象为基本单位，通过封装、继承和多态等特性实现程序的设计和实现。
类：就是一个模版。    属性和行为      变量和方法
对象：按照类这个模版创造出来的真实的实物。
实例化：从类到对象的过程
抽象化：从对象到类的过程
类的定义：
class 类名:
    类体
类的调用

变量 = 类名()
变量.变量名\方法名

继承：
    单继承：父类只有一个类
    多继承：父类有两个或两个以上的类

class 类名(父类的类名)：
    类体

多态：
    1、方法重写：在子类中定义和父类重名的方法，但是重新编写方法体，这样实现方法重写。
    2、方法重载：在同一类中定义多个重名的方法，但是每个方法传入的参数不同



"""
# class Student:
#     def __init__(self,name,age,sex,score,school):
#         self.name = name
#         self.age = age
#         self.sex = sex
#         self.score = score
#         self.school = school
#
#     def study(self):
#         print(self.name + '正在学习')
#
#     def show(self):
#         print('姓名：%s，年龄：%d，性别：%s，成绩：%d，学校：%s' % (self.name, self.age, self.sex, self.score, self.school))
#
#     def run(self):
#         print(self.name + '正在跑步')
# s1 = Student('张三',18,'男',90,'清华大学')
# s1.age = 19
# s1.study()
# s1.run()
# s1.show()

# class Person:
#
#     def __init__(self, name, age, sex):
#         self.name = name
#         self.age = age
#         self.sex = sex
#
#     def eat(self, food):
#         print(self.name + '正在吃' + food)
#
#     def sleep(self):
#         print(self.name + '正在睡觉')
#
# class Student(Person):
#     def __init__(self, name, age, sex,score,school):
#         super().__init__(name, age, sex)
#         self.score = score
#         self.school = school
#
#     def study(self):
#         print(self.name + '正在学习')
#
#     def show(self):
#         print('姓名：%s，年龄：%d，性别：%s' % (self.name, self.age, self.sex))
#
# s1 = Student('张三',18,'男',90,'清华大学')
# s1.eat('西红柿炒鸡蛋')
# s1.sleep()
# s1.study()
# s1.show()

# class Animal:
#     def __init__(self, name):
#         self.name = name
#
#     def eat(self, food):
#         print(self.name + '正在吃' + food)
#
#     def sleep(self):
#         print(self.name + '正在睡觉')
#
# class Bird(Animal):
#     def fly(self):
#         print(self.name + '正在飞')
#
# class Fish(Animal):
#     def swim(self):
#         print(self.name + '正在游泳')
#
# class Penguin(Bird, Fish):
#
#     def run(self):
#         print(self.name + '正在奔跑')
#
# p1 = Penguin('企鹅')
# p1.eat('扇贝')
# p1.sleep()
# p1.fly()
# p1.swim()
# p1.run()

# class A:
#     def print_a(self):
#         print("我是A类")
#
# class B(A):
#     def print_a(self):
#         print("我是B类")
#
# b = B()
# b.print_a()


# class Calc:
#     @staticmethod
#     def add(a,b):
#         return a + b
#
# print(Calc().add(1,2))



class Hvac:
    def __init__(self, brand, price):
        self.__brand = brand
        self.__price = price

    def get_brand(self):
        return self.__brand

    def get_price(self):
        return self.__price

    def turn_on(self):
        print("空调开机了。。。")

    def turn_off(self, time):
        print(f"空调将在{time} 分钟后会自动关机")


class test:
    h1 = Hvac("美的", 3000)
    print(h1.get_brand())
    print(h1.get_price())
    h1.turn_on()
    h1.turn_off(10)


class Person:
    def __init__(self, name, age, gender, tel, brand, capacity, screen_size, maximum_standby_time, integral):
        self.name = name
        self.age = age
        self.gender = gender
        self.tel = tel
        self.brand = brand
        self.capacity = capacity
        self.screen_size = screen_size
        self.maximum_standby_time = maximum_standby_time
        self.integral = integral

    def call(self, time, number):
        if number is not None:
            if self.tel < 1:
                print("通话次数已用完！")
            else:
                if time <= 10:
                    self.tel -= 1 * time
                    self.integral += 15 * time
                    print(
                        f"{self.name}打给{number}，打{time} 分钟电话，剩余话费余额{self.tel} 元，积分为{self.integral} 点")
                elif 10 < time <= 20:
                    self.tel -= 0.8 * time
                    self.integral += 39 * time
                    print(
                        f"{self.name}打给{number}，打{time} 分钟电话，剩余话费余额{self.tel} 元，积分为{self.integral} 点")
                else:
                    self.tel -= 0.65 * time
                    self.integral += 48 * time
                    print(
                        f"{self.name}打给{number}，打{time} 分钟电话，剩余话费余额{self.tel} 元，积分为{self.integral} 点")

            if self.tel < 0:
                print("已欠费，请及时充值！")
        else:
            print("请输入电话号码！")


p1 = Person("张三", 25, "男", 100, "小米", 500, 6.5, 10, 100)
p1.call(15, 123456789123)


class Student:
    def __init__(self, sno, name, age, gender, height, weight, score, address, tel):
        self.sno = sno
        self.name = name
        self.age = age
        self.gender = gender
        self.height = height
        self.weight = weight
        self.score = score
        self.address = address
        self.tel = tel

    def study(self, time):
        print(f"{self.name}正在学习，学习{time} 小时")

    def play_game(self, game_name):
        print(f"{self.name}正在玩{game_name} ！")

    def code(self, number):
        print(f"{self.name}正在写代码，写了{number} 行")

    def sum(self, *args):
        total = 0
        for i in args:
            total += i
        return total


class Car:
    def __init__(self, brand, number, color, weight, fuel_tank_storage_size):
        self.brand = brand
        self.number = number
        self.color = color
        self.weight = weight
        self.fuel_tank_storage_size = fuel_tank_storage_size

    def run(self, fun):
        print(f"{self.brand} {self.number} 正在{fun} ！")


c1 = Car("宝马", "四驱", "红色", 2500, 50)
c1.run("赛车")
c2 = Car("法拉利", "四驱", "白色", 1800, 35)
c2.run("赛车")
c3 = Car("铃木", "两驱", "黑色", 1500, 25)
c3.run("越野")
c4 = Car("五菱", "两驱", "蓝色", 1200, 20)
c4.run("赛车")
c5 = Car("拖拉机", "两驱", "绿色", 3000, 15)
c5.run("越野")


class Laptop:
    def __init__(self, brand, time, color, weight, cpu, memory_size, hard_disk_size):
        self.brand = brand
        self.time = time
        self.color = color
        self.weight = weight
        self.cpu = cpu
        self.memory_size = memory_size
        self.hard_disk_size = hard_disk_size

    def use(self, game_name):
        print(f"{self.brand} 正在运行{game_name} ！")

    def work(self, time):
        print(f"{self.brand} 正在办公，工作{time} 小时")


l1 = Laptop("戴尔", 15, "黑色", 200, "i7-10700", 16, 500)
l1.use("lol")
l1.work(8)


class Monkey:
    def __init__(self, breed, gender, color, weight):
        self.breed = breed
        self.gender = gender
        self.color = color
        self.weight = weight

    def fire(self, stuff):
        print(f"{self.breed} 正在使用{stuff}造火")

    def study(self, *args):
        for i in args:
            print(f"{self.breed}学习{i}")


m1 = Monkey("银背大猩猩", "雄性", "黑色", 500)
m1.fire("木棍")
m1.study("造石器", "狩猎", "捕鱼")




